package me.skyun.androidarch.connect;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;

import java.io.IOException;
import java.util.UUID;

/**
 * Created by skyun on 17/8/21.
 */

public class BluetoothClient extends ConnClient<BluetoothSocket> {

    private BluetoothDevice mServerDevice;
    private UUID mUUID;

    public BluetoothClient(BluetoothDevice serverDevice, UUID uuid, Connection.Callback callback) {
        super(callback);
        mServerDevice = serverDevice;
        mUUID = uuid;
    }

    @Override
    protected BluetoothSocket connect() throws IOException {
        return mServerDevice.createRfcommSocketToServiceRecord(mUUID);
    }

    @Override
    protected String getRemoteName() {
        return mServerDevice.getName();
    }
}
